<?php
namespace app\controller;

use app\model\NavSiteType;
use think\facade\Db;
use app\model\ProjectOpenSource;
use app\model\Book;

class Index extends Base
{
    /**
     * [index 首页]
     * @since  2022-03-18
     * @author Dai哥
     * @return [type]     [description]
     */
    public function index()
    {
        # 热门常用
        $hosArr = [
            [
                'name'  => '腾讯云',
                'color' => '#f1716c',
                'link'  => 'https://cloud.tencent.com/',
            ],
            [
                'name'  => '百度',
                'color' => '#384253',
                'link'  => 'http://www.baidu.com',
            ],
            [
                'name'  => 'Google',
                'color' => '#7773d7',
                'link'  => 'http://www.google.com',
            ],
            [
                'name'  => '汉译英',
                'color' => '#d15451',
                'link'  => 'https://fanyi.baidu.com/',
            ],
            [
                'name'  => 'CSDN',
                'color' => '#cf6c03',
                'link'  => 'https://www.csdn.net/',
            ],
            [
                'name'  => 'GitHub',
                'color' => '#e9b712',
                'link'  => 'https://github.com/',
            ],
            [
                'name'  => '掘金',
                'color' => '#179b47',
                'link'  => 'https://juejin.cn/',
            ],
            [
                'name'  => '书栈网',
                'color' => '#7dc22d',
                'link'  => 'https://www.bookstack.cn/',
            ],
            [
                'name'  => '知乎',
                'color' => '#677ecf',
                'link'  => 'https://www.zhihu.com/',
            ],
            [
                'name'  => '简书',
                'color' => '#896eca',
                'link'  => 'https://www.jianshu.com/',
            ],
            [
                'name'  => '博客园',
                'color' => '#b2b2b2',
                'link'  => 'https://www.cnblogs.com/',
            ],
            [
                'name'  => 'Boss直聘',
                'color' => '#8783e1',
                'link'  => 'https://www.zhipin.com/',
            ],
            [
                'name'  => 'B站',
                'color' => '#fac413',
                'link'  => 'https://www.bilibili.com/',
            ],
            [
                'name'  => '极客',
                'color' => '#f1716c',
                'link'  => 'http://gk.link/a/11aSp',
            ],
        ];

        # 菜单分类
        $typeList = NavSiteType::getTypeList();

        # 获取分类关联导航数据
        $typeListArr = NavSiteType::getTypeListArr();

        # 最新收录的10条
        $nowPjList = ProjectOpenSource::getProjectList([
            'page'  => 1,
            'limit' => 10,
            'sort'  => 'create_time',
        ]);

        $hotList = Book::getBookList(['page' => 1, 'limit'=>5]);

        return view('index', compact('typeListArr', 'typeList', 'nowPjList', 'hosArr', 'hotList'));
    }
}
